﻿using System;
using System.Collections.Generic;

using MonPocGarage.ArmyContracts.Common;
using MonPocGarage.ArmyContracts.Common.Enums;

namespace MonPocGarage.ArmyContracts
{
    public class Building : ICloneable
    {
        public string BuildingName { get; set; }

        public string BuildingID
        {
            get { return BuildingName.Replace(" ", "_"); }
        }

        public Guid InstanceKey { get; private set; }

        public string ImagePath { get { return BuildImagePath(); } }

        public int Defense { get; set; }

        public int Energy { get; set; }

        public List<IAbility> Abilities { get; set; }

        public HazardType HazardType { get; set; }

        public Building()
        {
            InstanceKey = Guid.NewGuid();
        }

        internal Building(Building another)
        {
            BuildingName = another.BuildingName;
            InstanceKey = Guid.NewGuid();
            Defense = another.Defense;
            Energy = another.Energy;
            Abilities = another.Abilities;
            HazardType = another.HazardType;
        }

        private string BuildImagePath()
        {
            if (!string.IsNullOrWhiteSpace(BuildingID))
            {
                string imagePath = string.Format("{0}/Images/Buildings/{1}.png",
                                                 Environment.CurrentDirectory,
                                                 BuildingName.Replace(" ", "_"));
                return imagePath;
            }
            return string.Empty;
        }

        public object Clone()
        {
            return new Building(this);
        }
    }
}
